<?php
namespace Amis\form;
class Textarea extends FormItem
{
    public string $type = 'textarea';

    /**
     * 最小行数
     * @param $minRows
     * @return $this
     */
    public function minRows(int $minRows = 3)
    {
        $this->minRows = $minRows;
        return $this;
    }

    /**
     * 最大行数
     * @param $maxRows
     * @return $this
     */
    public function maxRows(int $maxRows = 20)
    {
        $this->maxRows = $maxRows;
        return $this;
    }

    /**
     * 是否去除首尾空白文本。
     * @param bool $trimContents
     * @return $this
     */
    public function trimContents(bool $trimContents = true)
    {
        $this->trimContents = $trimContents;
        return $this;
    }

    /**
     * 只读
     * @param bool $readOnly
     * @return $this
     */
    public function readOnly(bool $readOnly = false)
    {
        $this->readOnly = $readOnly;
        return $this;
    }

    /**
     * 是否显示计数器
     * @param bool $showCounter
     * @return $this
     */
    public function showCounter(bool $showCounter)
    {
        $this->showCounter = $showCounter;
        return $this;
    }

    /**
     * 限制最大字数
     * @param int $maxLength
     * @return $this
     */
    public function maxLength(int $maxLength)
    {
        $this->maxLength = $maxLength;
        return $this;
    }

    public function clearable(string $clearable = 'label')
    {
        $this->clearable = $clearable;
        return $this;
    }

    /**
     * 清除后设置此配置项给定的值。
     * @param string $resetValue
     * @return $this
     */
    public function resetValue(string $resetValue = '')
    {
        $this->resetValue = $resetValue;
        return $this;
    }
}